/*
 * Person.java
 * 
 * Created on 19-jun-2007, 20:51:28
 * 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.i2a.peacsy.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Tortuga
 */
@Entity
@Table(name = "TA_PERS_PERSONS")
@NamedQueries({@NamedQuery(name = "Person.findByPersCoCode", query = "SELECT p FROM Person p WHERE p.persCoCode = :persCoCode"), @NamedQuery(name = "Person.findByPersIdIdentityNumber", query = "SELECT p FROM Person p WHERE p.persIdIdentityNumber = :persIdIdentityNumber"), @NamedQuery(name = "Person.findByPersLiFirstName", query = "SELECT p FROM Person p WHERE p.persLiFirstName = :persLiFirstName"), @NamedQuery(name = "Person.findByPersLiSecondName", query = "SELECT p FROM Person p WHERE p.persLiSecondName = :persLiSecondName"), @NamedQuery(name = "Person.findByAudiInSituation", query = "SELECT p FROM Person p WHERE p.audiInSituation = :audiInSituation"), @NamedQuery(name = "Person.findByAudiDaCreationDate", query = "SELECT p FROM Person p WHERE p.audiDaCreationDate = :audiDaCreationDate"), @NamedQuery(name = "Person.findByAudiLiCreationUsr", query = "SELECT p FROM Person p WHERE p.audiLiCreationUsr = :audiLiCreationUsr"), @NamedQuery(name = "Person.findByAudiDaUpdateDate", query = "SELECT p FROM Person p WHERE p.audiDaUpdateDate = :audiDaUpdateDate"), @NamedQuery(name = "Person.findByAudiLiUpdateUsr", query = "SELECT p FROM Person p WHERE p.audiLiUpdateUsr = :audiLiUpdateUsr")})
public class Person implements Serializable {

  @Id
  @Column(name = "PERS_CO_CODE", nullable = false)
  private Integer persCoCode;

  @Column(name = "PERS_ID_IDENTITY_NUMBER")
  private Integer persIdIdentityNumber;

  @Column(name = "PERS_LI_FIRST_NAME")
  private String persLiFirstName;

  @Column(name = "PERS_LI_SECOND_NAME")
  private String persLiSecondName;

  @Column(name = "AUDI_IN_SITUATION")
  private Short audiInSituation;

  @Column(name = "AUDI_DA_CREATION_DATE")
  @Temporal(TemporalType.TIMESTAMP)
  private Date audiDaCreationDate;

  @Column(name = "AUDI_LI_CREATION_USR")
  private String audiLiCreationUsr;

  @Column(name = "AUDI_DA_UPDATE_DATE")
  @Temporal(TemporalType.TIMESTAMP)
  private Date audiDaUpdateDate;

  @Column(name = "AUDI_LI_UPDATE_USR")
  private String audiLiUpdateUsr;

  @OneToMany(mappedBy = "persCoCode")
  private Collection<User> userCollection;

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "persCoCode")
  private Collection<WalletAccount> walletAccountCollection;
    protected static org.apache.commons.logging.Log
        log = org.apache.commons.logging.LogFactory.getLog(Person.class);

    public Person() {
    }

  public Person(Integer persCoCode) {
    this.persCoCode = persCoCode;
  }

  public Integer getPersCoCode() {
    return persCoCode;
  }

  public void setPersCoCode(Integer persCoCode) {
    this.persCoCode = persCoCode;
  }

  public Integer getPersIdIdentityNumber() {
    return persIdIdentityNumber;
  }

  public void setPersIdIdentityNumber(Integer persIdIdentityNumber) {
    this.persIdIdentityNumber = persIdIdentityNumber;
  }

  public String getPersLiFirstName() {
    return persLiFirstName;
  }

  public void setPersLiFirstName(String persLiFirstName) {
    this.persLiFirstName = persLiFirstName;
  }

  public String getPersLiSecondName() {
    return persLiSecondName;
  }

  public void setPersLiSecondName(String persLiSecondName) {
    this.persLiSecondName = persLiSecondName;
  }

  public Short getAudiInSituation() {
    return audiInSituation;
  }

  public void setAudiInSituation(Short audiInSituation) {
    this.audiInSituation = audiInSituation;
  }

  public Date getAudiDaCreationDate() {
    return audiDaCreationDate;
  }

  public void setAudiDaCreationDate(Date audiDaCreationDate) {
    this.audiDaCreationDate = audiDaCreationDate;
  }

  public String getAudiLiCreationUsr() {
    return audiLiCreationUsr;
  }

  public void setAudiLiCreationUsr(String audiLiCreationUsr) {
    this.audiLiCreationUsr = audiLiCreationUsr;
  }

  public Date getAudiDaUpdateDate() {
    return audiDaUpdateDate;
  }

  public void setAudiDaUpdateDate(Date audiDaUpdateDate) {
    this.audiDaUpdateDate = audiDaUpdateDate;
  }

  public String getAudiLiUpdateUsr() {
    return audiLiUpdateUsr;
  }

  public void setAudiLiUpdateUsr(String audiLiUpdateUsr) {
    this.audiLiUpdateUsr = audiLiUpdateUsr;
  }

  public Collection<User> getUserCollection() {
    return userCollection;
  }

  public void setUserCollection(Collection<User> userCollection) {
    this.userCollection = userCollection;
  }

  public Collection<WalletAccount> getWalletAccountCollection() {
    return walletAccountCollection;
  }

  public void setWalletAccountCollection(Collection<WalletAccount> walletAccountCollection) {
    this.walletAccountCollection = walletAccountCollection;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (persCoCode != null ? persCoCode.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Person)) {
      return false;
    }
    Person other = (Person) object;
    if (this.persCoCode != other.persCoCode && (this.persCoCode == null || !this.persCoCode.equals(other.persCoCode))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "org.i2a.peacsy.entity.Person[persCoCode=" + persCoCode + "]";
  }

}
